package com.yunqian.util.bean;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.log4j.Logger;

/**
 * @author zou
 * @describe 实体转换工具
 * @date 2018/6/25
 */
public class BeanUtil extends BeanUtils {

    private static Logger logger = Logger.getLogger(BeanUtil.class);

    static {
        ConvertUtils.register(new StrToDateConverter(), java.util.Date.class);
    }

    /**
     * 将源对象中的非空属性值拷贝到目标对象中
     *
     * @param dest
     * @param orig
     */
    public static void copyNotNullProperties(Object dest, Object orig) {
        try {
            BeanUtilBean.getInstance().copyNotNullProperties(dest, orig);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new RuntimeException(e);
        }
    }


}
